package com.douwong.student.popuwindow;

import android.app.Dialog;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.WindowManager;
import android.widget.TextView;

import com.douwong.student.R;


/**
 * 是否提交对话框
 * @author Administrator
 *
 */
public class SubmitDialog {
	private static SubmitDialog instance;
	public MonClick onclick;
	public SubmitDialog(){
		
	}
	public static SubmitDialog getInstance(){
		if(instance==null){
			instance=new SubmitDialog();
		}
		return instance;
	}
	public Dialog dialog;

	/**
	 * 显示提交Dialog
	 * @param context
	 * @param str
     */
	public void ShowSubmitDialog(final Context context, String str ){
		View view= LayoutInflater.from(context).inflate(R.layout.version_update_layout,null);
		TextView content=(TextView) view.findViewById(R.id.content);
		content.setText(str);
		TextView confire=(TextView) view.findViewById(R.id.update_text);
		confire.setText("确定");
		TextView cancel=(TextView) view.findViewById(R.id.not_update_text);
		cancel.setText("取消");
		
		dialog=new Dialog(context,R.style.Dialog_Fullscreen);
		dialog.getWindow()
		.setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
		dialog.setContentView(view);
		dialog.show();
        confire.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				dialog.dismiss();
				onclick.confireClick();
			}
		});
		cancel.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				dialog.dismiss();
				onclick.cancelClick();
			}
		});
	}
	public interface MonClick{
		void confireClick();
		void cancelClick();
	}
	public void setMClick(MonClick onclick){
		this.onclick=onclick;
	}
}
